import java.util.ArrayList;

public class ArrayListTest {

    public static void main(String[] args) {

        ArrayList list = new ArrayList();
        Student2 stu1 = new Student2(1,"张三");
        Student2 stu2 = new Student2(2,"李四");
        Student2 stu3 = new Student2(3,"王五");
        list.add(stu1);
        list.add(stu2);
        list.add(stu3);
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }

        System.out.println("--------------------------------------");

        Student2 stu4 = new Student2(1,"张三丰");
        list.add(0,stu4);
        list.remove(1);
        list.remove(2);
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
    }

}
